package com.xiang.design.chainResponsibility.Impl;

import com.xiang.design.chainResponsibility.Handle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * A处理
 *
 * @author xiangtianlei
 * @date 2023/03/15
 */
public class GroupHandle implements Handle {
    protected final Logger logger = LoggerFactory.getLogger(GroupHandle.class);
    Handle nextHandle;

    /**
     * 设置下一个处理
     *
     * @param handle 处理
     */
    @Override
    public void setNextHandle(Handle handle) {
        this.nextHandle = handle;
    }

    /**
     * 处理
     *
     * @param amount 数量
     * @return boolean
     */
    @Override
    public boolean handle(int amount) {
        if (amount > 1000) {
            logger.warn("金额较大,小组领导无权限审批");
            return nextHandle.handle(amount);
        }
        logger.info("小组领导有权限处理,无需上级领导审批");
        return true;
    }
}
